package xkp.lesson5;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class MainUi extends JFrame {
    public MainUi(){
        //设置窗体尺寸
        this.setSize(600,260);
        //禁止改变大小
        this.setResizable(false);
        this.setTitle("主页面");
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //LoginUI没有任何元素，希望在其中添加元素
        //JButton按钮
        //入如果需要在JFrame中添加元素，必须要设置布局管理器
        //指定JFrame该如何布局
        //此时指定布局为流式布局
        //流式布局管理器默认水平居中
        //FlowLayout flowLayout = new FlowLayout(FlowLayout.RIGHT);
        FlowLayout flowLayout = new FlowLayout(FlowLayout.CENTER);
        this.setLayout(flowLayout);

        JButton showGetDataBtn = new JButton("爬取数据");
        showGetDataBtn.setFont(new Font("楷体",Font.BOLD,30));
        showGetDataBtn.setPreferredSize(new Dimension(280,200));
        this.add(showGetDataBtn);
        /*showGetDataBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });*/
        showGetDataBtn.addActionListener(e->{
            new ReadDataUi();
        });


        JButton showManageDataBtn = new JButton("管理数据");
        showManageDataBtn.setFont(new Font("楷体",Font.BOLD,30));
        showManageDataBtn.setPreferredSize(new Dimension(280,200));
        this.add(showManageDataBtn);

        this.setVisible(true);

    }

}
